<?php
declare(strict_types=1);
 

namespace App\Fastapp\Mapper;

use App\Fastapp\Model\FastappPay;
use Hyperf\Database\Model\Builder;
use Mine\Abstracts\AbstractMapper;
use Mine\Helper\Str;

/**
 * 支付平台Mapper类
 */
class FastappPayMapper extends AbstractMapper
{
    /**
     * @var FastappPay
     */
    public $model;

    public function assignModel()
    {
        $this->model = FastappPay::class;
    }

    /**
     * 搜索处理器
     * @param Builder $query
     * @param array $params
     * @return Builder
     */
    public function handleSearch(Builder $query, array $params): Builder
    {

        return $query;
    }

    public function update(mixed $id, array $data): bool
    {
        if (parent::update($id, $data)) {
            $code = $this->model::query()->where(['id' => $id])->value('code');
            $cs = '\\App\\Fastapp\\Api\\Service\\Pay\\Platform\\' . Str::studly($code) . 'Service';
            $cs::getConfig(true);
            return true;
        }
        return false;
    }
}